import numpy as np


def dp_opt(arr):
    opt = np.zeros(len(arr))
    opt[0] = arr[0]
    opt[1] = max(arr[0], opt[1])
    for i in range(2, len(arr)):
        opt[i] = max(opt[i - 2] + arr[i], opt[i - 1])
    return opt[len(arr) - 1]

arr = [1, 2, 4, 1, 7, 8, 3]
print('---dp_opt')
print(dp_opt(arr))
